/**
 * Created by joylee on 2019/2/15.
 */
const puppeteer = require('puppeteer')
const devices = require('puppeteer/DeviceDescriptors')

;(async () => {
  const browser = await puppeteer.launch()
  const page = await browser.newPage()
  await page.emulate(devices['iPhone X'])
  await page.goto('https://www.baidu.com')

  // 搜索内容
  await page.type('#index-kw', 'Google')

  await page.click('#index-bn')

  await page.waitForNavigation()
  await page.screenshot({path: 'baidu.png'})
  await browser.close()
})()
